package cn.edu.jxau.test;

import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.concurrent.ExecutionException;

public class Main {

	public static void main(String[] args) throws InterruptedException, ExecutionException {

		Node<Integer> root = new Node<>(8);
		root.right = new Node<>(7);
		root.left = new Node<>(8);
		root.left.left = new Node<>(9);
		root.left.right = new Node<>(2);
		root.left.right.left = new Node<>(4);
		root.left.right.right = new Node<>(7);
		preOrder(root);
		mirror(root);
		System.out.println();
		preOrder(root);
	}

	public static <T> void preOrder(Node<T> root) {
		if (root == null) {
			return;
		}
		System.out.print(root.data + "\t");
		preOrder(root.left);
		preOrder(root.right);
	}

	public static <T> void mirror(Node<T> root) {

		if (root == null)
			return;
		Node<T> temp = root.left;
		root.left = root.right;
		root.right = temp;
		mirror(root.left);
		mirror(root.right);
	}
}

class Node<T> {

	public T data;
	public Node<T> left;
	public Node<T> right;

	public Node() {

	}

	public Node(T data) {
		this.data = data;
	}
}